class Solution {
public:
    int compare(string version1, string version2) {
        int n1 = v1.size(), n2 = v2.size();
        int l = 0, r = 0;
        while(l < n1 || r < n2) {
            long long num1 = 0;
            while (l < n1 && v1[l] != '.') {
                num1 = num1 * 10 + (v1[l] - '0');
                l++;
            }
            l++;
            long long num2 = 0;
            while (r < n2 && v2[r] != '.') {
                num2 = num2 * 10 + (v2[r] - '0');
                r++;
            }
            r++;
            if (num1 > num2) return 1;
            else if (num1 < num2) return -1;
        }
        return 0;
    }
};